<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .container{
            position: relative;
            width: 450px;
            height: 450px;
            border: 1px solid #ddd;
            box-sizing: border-box;
            background-image: url('../images/small.jpg') ;
            background-size: 100% 100%;
        }
        .move-box{
            position: absolute;
            left: 0; 
            width: 300px;
            top: 0;
            height: 300px;
            background: #fede4f;
            opacity: 0.5;
        }
        .large-box{
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            opacity: 0.2;
            z-index: 10;
        }
        .big-img-box{
            width: 450px;
            height: 450px;
            overflow: hidden;
            position: absolute;
            top: 0;
            left: 450px;
            z-index: 100;
            border: 1px solid red;
        }
        .big-img-box img{
            position: absolute;
            top: 0;
            left: 0;
        }
        
    </style>
</head>
<body>
    <div class="container">
        <div class="move-box"></div>

        <div class="large-box"></div>
        <div class="big-img-box">
            <img src="../images/big.jpg" alt="">
        </div>
    </div>

    <script>
        var largeBox=document.querySelector('.large-box')
        var moveBox=document.querySelector(".move-box")
        var moveImg=document.querySelector('.big-img-box img')
         
            largeBox.onmousemove=function(event){
          //  console.log(event.target)
            var left=event.offsetX-150
            var top=event.offsetY-150

           
            if (event.offsetX<=150){
                left=0
            }
            if (event.offsetY<=150){
               top=0
            }
            if (event.offsetX>=300){
                left=150
            }
            if (event.offsetY>=300){
               top=150
            }

            moveBox.style.top=top+'px'
            moveBox.style.left=left+'px'

            moveImg.style.top=-(top*+(16/7))+'px'
            moveImg.style.left=-(left*+(16/7))+'px'
        }
    </script>
</body>
</html>